<extend name="Base/common"/>
<block name="style">
    <link href="__CSS__/video.css" rel="stylesheet" type="text/css"/>
</block>
<if condition="check_auth('addVideoContent')">
<block name="body">
<div class="aw-publish">
    <div class="aw-publish-header">
		<h1 style="padding:40px;">上传视频</h1>
	</div>
	<div class="aw-publish-body clearfix">
		<form class="form-horizontal  ajax-form" role="form"  action="{:U('Video/Index/doPost')}" method="post">
		<input id="video_top" name="video_id" type="hidden" value="13">
		<div class="col-md-6 aw-main-content">
			<div class="aw-mod aw-mod-publish">
				<div class="mod-body">
					<h3 class="upload-youku">温馨提示：视频上传功能由优酷提供合作技术支持</h3>
					<div class="aw-mod upload-youku">
						<div style="margin-bottom: 10px;"><a href="#frm-post-popup" class="open-popup-link"><img src="__THEME_PUBLIC__/images/youku.png" /></a></div>
						<input id="url" name="url" type="text" class="form-control" value="" placeholder="输入以http://开头以.swf结尾的视频地址"/>
						<input type='hidden' value="" name="video" id="video">
						<input type="hidden" value="1" name="is_youku" />
					</div>
					<h3>上传封面：<span style="color:#ffaf86">支持jpg、png、gif等图片格式，请勿上传违法图片！</span></h3>
					<div class="aw-publish-title">
						<input type="file" id="upload_picture_cover">
                        <div class="upload-img-box" style="width:208px;margin-top: 10px;">
                            <div style="background:url(__THEME_PUBLIC__/images/img50.png) #fff no-repeat center;height:118px;border-radius: 15px;"></div>
                        </div>
                        <input type="hidden" name="cover_id" id="cover_id_cover" value=""/>
					</div>
					<h3>标题 (必填)：</h3>
					<div class="aw-publish-title">
						<div>
							<input id="title" name="title" type="" class="form-control" value="" placeholder="标题"/>
						</div>
					</div>
				
					<h3>描述：</h3>
					<div class="aw-mod aw-editor-box">
						<div class="mod-head">
							<div class="wmd-panel">
								<textarea class="form-control" rows="4" name="content" placeholder="填写关于话题的简单介绍！"></textarea>
							</div>
						</div>
					</div>
					
					<h3>发布到以下树丛：</h3>
					<div class="aw-topic-bar" data-type="publish">
						<input id="group" name="group" type="text" class="form-control" value="" placeholder="选择下方加入的树丛" readonly="true"/>
						<input id="group_id" name="group_id" type="hidden" value="" />
					</div>

					<h3>我加入的树丛：</h3>
					<div class="aw-topic-bar">
						<div class="topic-bar clearfix">	
							<volist name="group" id="vo">
								<span class="topic-tag" onclick="$('#group').val('{$vo.title}');$('#group_id').val('{$vo.id}');$('.topic-bar').find('a').removeClass('active');$(this).find('a').addClass('active');">
								<a class="text">{$vo.title}</a>
							</span>
							</volist>
						</div>
					</div>
					<h3>分享志同道合的树友：</h3>
					<div class="aw-friend">
						<ul>
				
						</ul>
					</div>
				</div>
			</div>
		</div>
		<div class="col-md-6 aw-side-bar">
			<div class="friendlist">
				<h2>选择树友列表</h2>
				<div class="bd">
					<ul>
						<volist name="friends" id="vo">
						<li>
							<div class="img">
							<a href="javascript:;"><img src="{$vo.user.avatar64}" alt="{$vo.user.nickname}" /></a>
							</div>
							<h3><a href="javascript:;">{$vo.user.nickname}</a></h3>
							<em class="addbtn" onclick="addfriend($(this),$(this).parents('li').find('img').attr('src'),{$vo.user.id})"></em>
						</li>
						</volist>
					</ul>
				</div>
			</div>
			<div class="col-md-12 text-center" style="margin-top:30px;">
				<button type="submit" class="btn btn-primary" style="width:300px;height:50px;background-color: #5ac994;border:none;" href="{:U('Video/Index/doPost')}">上传视频</button>
			</div>
			
		</div>
		</form>
	</div>
</div>
<include file="_box"/>
	</block>
	<block name="script">
        <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
        <script>
            $(function () {
                $('#top_nav >li >a ').mouseenter(function () {
                    $('.children_nav').hide();
                    $('#children_' + $(this).attr('data')).show();
                });
                $('.open-popup-link').magnificPopup({
                    type: 'inline',
                    midClick: true, // Allow opening popup on middle mouse click. Always set it to true if you don't provide alternative source in href.
                    closeOnBgClick:false
                });

                $('.open-popup-ajax').magnificPopup({
                    type: 'iframe',
                    midClick: true, // Allow opening popup on middle mouse click. Always set it to true if you don't provide alternative source in href.
                    closeOnBgClick:false
                });
                bind_support();
            })
            function addfriend(selector,img,uid){
				var fridennum=$(".aw-friend").find('li').length;
				if(fridennum<6){
					$('.aw-friend').find('ul').append(' <li id="'+uid+'"><img src="'+ img +'" /><input type=\'hidden\' value="'+ uid +'" name="friends[]"></li>');
					selector.parent('li').addClass('selected');
					selector.attr('onclick','cannelfriend($(this),'+uid+')');
				}else{
					alert('邀请人数超过指定数量！');
				}
			}
			function cannelfriend(selector,uid){
				$('.aw-friend').find('#'+uid+'').remove();
				selector.parent('li').removeClass('selected');
				selector.attr('onclick','addfriend($(this),$(this).parents(\'li\').find(\'img\').attr(\'src\'),'+uid+')');
			}
        </script>

        <script type="text/javascript">
            var SUPPORT_URL="{:addons_url('Support://Support/doSupport')}";
            //上传图片
            /* 初始化上传插件 */
            $("#upload_picture_cover").uploadify({
                "height"          : 30,
                "swf"             : "__STATIC__/uploadify/uploadify.swf",
                "fileObjName"     : "download",
                "buttonText"      : "上传封面",
                "buttonClass":"uploadcover",
                "uploader"        : "{:U('Core/File/uploadPicture',array('session_id'=>session_id()))}",
                "width"           : 100,
                'removeTimeout'	  : 1,
                'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
                "onUploadSuccess" : uploadPicturecover,
                'overrideEvents':['onUploadProgress','onUploadComplete','onUploadStart','onSelect'],
                'onFallback' : function() {
                    alert('未检测到兼容版本的Flash.');
                }, 'onUploadProgress': function (file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) {
                    $("#cover_id_cover").parent().find('.upload-img-box').html(totalBytesUploaded + ' bytes uploaded of ' + totalBytesTotal + ' bytes.');
                },'onUploadComplete' : function(file) {
                    //alert('The file ' + file.name + ' finished processing.');
                },'onUploadStart' : function(file) {
                    //alert('Starting to upload ' + file.name);
                },'onQueueComplete' : function(queueData) {
                    // alert(queueData.uploadsSuccessful + ' files were successfully uploaded.');
                }
            });
            function uploadPicturecover(file, data){
                var data = $.parseJSON(data);
                var src = '';
                if(data.status){
                    $("#cover_id_cover").val(data.id);
                    src = data.url ||  data.path
                    $('.upload-img-box').html(
                            '<div class="upload-pre-item"><img src="' + src + '"/></div>'
                    );
                } else {
                    toast.error('封面上传失败。','温馨提示');
                }
            }
        </script>
    </block>
</if>
